package com.copm.demonstrationsystem.controller.introductionfeatures;

import com.copm.demonstrationsystem.commons.response.ResponseStatus;
import com.copm.demonstrationsystem.commons.util.ControllerUtils;
import com.copm.demonstrationsystem.service.introductionfeatures.ProjectIntroductionService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


/**
 * @Author: Yuan Baiyu
 * @Date: Created in 18:47 2018/4/22
 */
@RestController
@RequestMapping("/project")
@CrossOrigin
public class ProjectIntroductionController {

    @Autowired
    ProjectIntroductionService projectIntroductionService;

    //获取“项目介绍”页面信息
    @ApiOperation("项目介绍页面的信息获取接口")
    @GetMapping
    public ResponseStatus getPage() {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                projectIntroductionService.getProjectIntroductionPage());
    }

    //修改“项目介绍”页面文本信息
    @PostMapping("/text")
    @ApiOperation("修改文本")
    @ApiImplicitParam(name = "introduction", value = "新的文本内容"
            , dataType = "String", paramType = "query", required = true)
    public ResponseStatus modifyText(@RequestParam("introduction") String introduction) {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                projectIntroductionService.modifyProjectIntroductionText(introduction));
    }

    //修改“项目介绍”页面图片信息
    @PostMapping("/image")
    @ApiOperation("修改图片")
    @ApiImplicitParam(name = "file", value = "新的图片"
            , dataType = "file", paramType = "form", required = true)
    public ResponseStatus modifyImage(@RequestPart("file") MultipartFile file){
        return ControllerUtils.fillResponse(new ResponseStatus(),
                projectIntroductionService.modifyProjectIntroductionImage(file));
    }

//    //添加“项目介绍”页面文本信息
//    @PostMapping("/text")
//    @ApiOperation("添加文本")
//    @ApiImplicitParam(name = "introduction", value = "文本内容"
//            , dataType = "String", paramType = "query", required = true)
//    public ResponseStatus addText(@RequestParam("introduction") String introduction) {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                projectIntroductionService.modifyProjectIntroductionText(introduction));
//    }

//    //删除“项目介绍”页面图片信息
//    @DeleteMapping("/image")
//    @ApiOperation("图片删除")
//    public ResponseStatus deleteImage() {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                projectIntroductionService.deleteProjectIntroductionImage());
//    }
//
//    //添加“项目介绍”页面图片信息
//    @PostMapping("/image")
//    @ApiOperation("图片添加")
//    @ApiImplicitParam(name = "file", value = "页面图片信息"
//            , dataType = "file", paramType = "form", required = true)
//    public ResponseStatus addImage(@RequestPart("file") MultipartFile file) {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                projectIntroductionService.addProjectIntroductionImage(file));
//    }
}
